package com.itboye.zhujia.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.itboye.zhujia.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
 * 发布
 *
 */
public class MyFaBuAdapter extends BaseAdapter {
	private Context context;
	
	List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
	
	public MyFaBuAdapter(Context context,List<Map<String, Object>> list) {
		this.context=context;
		this.list=list;
	}
	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder=null;
		if(view==null){
			holder=new ViewHolder();
			view=LayoutInflater.from(context).inflate(R.layout.item_fa_bu, null);
			holder.fabu_zhuangtai=(TextView) view.findViewById(R.id.fabu_zhuangtai);
			holder.fabu_img=(ImageView) view.findViewById(R.id.fabu_img);
			holder.fabu_title=(TextView) view.findViewById(R.id.fabu_title);
			holder.fabu_content=(TextView) view.findViewById(R.id.fabu_content);
			holder.fabu_zhuangtai02=(TextView) view.findViewById(R.id.fabu_zhuangtai02);
			holder.fabu_money=(TextView) view.findViewById(R.id.fabu_money);
			holder.fabu_xiajia=(TextView) view.findViewById(R.id.fabu_xiajia);
			holder.fabu_shuaxin=(TextView) view.findViewById(R.id.fabu_shuaxin);
			holder.fabu_fuwu=(TextView) view.findViewById(R.id.fabu_fuwu);
			holder.fabu_xuanze=(TextView) view.findViewById(R.id.fabu_xuanze);
			
			view.setTag(holder);
		}else{
			holder=(ViewHolder) view.getTag();
		}
		holder.fabu_zhuangtai.setText(list.get(position).get("zt").toString());
		holder.fabu_img.setBackgroundResource(Integer.valueOf(list.get(position).get("img").toString()));
		holder.fabu_title.setText(list.get(position).get("title").toString());
		holder.fabu_content.setText(list.get(position).get("content").toString());
		holder.fabu_zhuangtai02.setText(list.get(position).get("zt02").toString());
		holder.fabu_money.setText(list.get(position).get("money").toString());
		holder.fabu_xiajia.setText(list.get(position).get("xiajia").toString());
		holder.fabu_shuaxin.setText(list.get(position).get("shuaxin").toString());
		holder.fabu_fuwu.setText(list.get(position).get("fuwu").toString());
		holder.fabu_xuanze.setText(list.get(position).get("xuanze").toString());
		return view;
	}
	
	class ViewHolder{
		TextView fabu_zhuangtai;
		ImageView fabu_img;
		TextView fabu_title;
		TextView fabu_content;
		TextView fabu_zhuangtai02;
		TextView fabu_money;
		TextView fabu_xiajia,fabu_shuaxin,fabu_fuwu,fabu_xuanze;
		
	}

}
